package com.mzy.linear_struct.hot100.二分查找;

import java.util.Arrays;

/**
 * @Author: mizy3
 * @Date: 2024/09/16/下午9:54
 * @Description:
 */
public class Pro34在排序数组中查找元素的第一个和最后一个位置 {
    public int[] searchRange(int[] nums, int target) {
        int left = 0, right = nums.length - 1;
        int mid = 0;
        while (left <= right) {
            mid = ((right - left) + right) >> 1;
            if (nums[mid] < target) {
                left = mid + 1;
            } else if (nums[mid] > target) {
                right = mid - 1;
            } else {
                break;
            }
        }
        return new int[]{-1, -1};
    }


    public float Method(float a,float b, float c){ return 0.0f;}
    public int Method(int a, int b){ return 0;}

    public static void main(String[] args) {
        System.out.println(Arrays.toString(new Pro34在排序数组中查找元素的第一个和最后一个位置().searchRange(new int[]{5, 7, 7, 8, 8, 10}, 8)));
    }
}


































